<?php
/*
 * @Author: your name
 * @Date: 2020-12-23 12:01:16
 * @LastEditTime: 2020-12-28 10:17:37
 * @LastEditors: your name
 * @Description: In User Settings Edit
 * @FilePath: /special/application/adminapiv3/controller/ServerDownloadController.php
 */

namespace app\adminapiv3\controller;

//下载
use app\adminapiv3\service\ServerDownload;
use think\Request;

class ServerDownloadController extends BaseController
{
    /**
     * @name 列表
     * @param $module模块 1=>Netfilter日志 2=>规则 3=>主机码文件下载 4=>linux安装包下载 5=>windows安装包下载 6=>linux更新包 7windows更新包
     * @author wx
     * @date 2019/11/4 13:40
     */
    public function list($module)
    {

        $server = new \app\adminapiv3\service\ServerDownload();

        $list = $server->list($module);

        return $this->jsonOutPut($list);
    }

    /**
     * @name 删除
     * @param $module
     * @author wx
     * @date 2019/11/4 13:59
     */
    public function del(Request $request)
    {
        $params = $request->only(['id']);

        $this->validate($params, 'ServerDownload.del');

        $server = new \app\adminapiv3\service\ServerDownload();
        $server->del($params['id']);

        return $this->jsonOutPut();
    }

    /**
     * @name 创建下载任务
     * @param $module
     * @author wx
     * @date 2019/11/5 10:29
     */
    public function create(Request $request)
    {
        $params = $request->only(['module', 'host_id', 'start_time', 'end_time']);


        $this->validate($params, 'ServerDownload.create');

        $server = new ServerDownload();

        $server->create($params['module'], $params);

        return $this->jsonOutPut();
    }
}